#https://gitee.com/xingchen_7/xingchen-java.git

#git checkout master
#git pull
#sh /var/jenkins_home/workspace/vue-admin/xingchen-admin-vue/jenkin_vue-admin.sh

# -----------------------------------build 结束之后 在宿主机里执行----------------------
TARGET_WORKSPACE='/home/xingchen/workspace/vue-admin'

cd ${TARGET_WORKSPACE}/xingchen-admin-vue

docker cp jenkins:/opt/data/vue /home/xingchen/workspace/vue-admin/xingchen-admin-vue/

# 构建镜像
cd vue

docker build  -f ${TARGET_WORKSPACE}/xingchen-admin-vue/Dockerfile -t registry.cn-hangzhou.aliyuncs.com/xingchen_1/vue-admin:1.0 .

docker push registry.cn-hangzhou.aliyuncs.com/xingchen_1/vue-admin:1.0

# 删除历史镜像
if [[ -n $(docker ps -a | grep vue-admin) ]];then
        echo "l【vue-admin】已运行，正在重启。。。"
        #停止之前的容器运行
        docker stop vue-admin

        #删除之前的容器
        docker rm vue-admin
else
        echo "【vue-admin】不存在，正在部署。。。"
fi

#运行刚刚创建的容器

#docker run  -v C:\Users\Administrator\nginx\logs:/etc/nginx/logs --name vue-admin --add-host mysql.xingchen:172.17.0.1   --add-host redis.xingchen:172.17.0.1  --add-host host.xingchen:172.17.0.1  -d -p 8080:8080 registry.cn-hangzhou.aliyuncs.com/xingchen_1/vue-admin:1.0
docker run  -v /home/xingchen/logs:/etc/nginx/logs --name vue-admin -m 800m --add-host mysql.xingchen:172.17.0.1   --add-host redis.xingchen:172.17.0.1  --add-host host.xingchen:172.17.0.1  -d -p 8080:8080 registry.cn-hangzhou.aliyuncs.com/xingchen_1/vue-admin:1.0
